package com.xuecheng.manage_course.controller;

import com.xuecheng.api.interaction.InteractionControllerApi;
import com.xuecheng.framework.domain.course.Interaction;
import com.xuecheng.framework.domain.course.request.InteractionRequest;
import com.xuecheng.framework.model.response.ResponseResult;
import com.xuecheng.framework.web.BaseController;
import com.xuecheng.manage_course.service.InteractionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Lyq
 * @version 1.0
 * @create 2019/11/2 10:48
 */
@RestController
@RequestMapping("/interaction")
public class InteractionController extends BaseController implements InteractionControllerApi {

    @Autowired
    InteractionService interactionService;

    @Override
    @GetMapping("/note/get/{courseId}")
    public Interaction getNote(@PathVariable("courseId") String courseId) {
        return interactionService.getNote(courseId);
    }

    @Override
    @PostMapping("/note/add")
    public ResponseResult addNote(@RequestBody InteractionRequest interactionRequest) {
        return interactionService.addNote(interactionRequest);
    }

    @Override
    @DeleteMapping("/note/delete")
    public ResponseResult delNote(@RequestParam("id") String id) {
        return interactionService.delNote(id);
    }

    @Override
    @GetMapping("/question/get/{courseId}")
    public Interaction getQuestion(@PathVariable("courseId") String courseId) {
        return interactionService.getQuestion(courseId);
    }

    @Override
    @PostMapping("/question/add")
    public ResponseResult addQuestion(@RequestBody InteractionRequest interactionRequest) {
        return interactionService.addQuestion(interactionRequest);
    }

    @Override
    @DeleteMapping("/question/delete")
    public ResponseResult delQuestion(@RequestParam("id") String id) {
        return interactionService.delQuestion(id);
    }

    @Override
    @PostMapping("/question/addanswer")
    public ResponseResult addAnswer(@RequestBody InteractionRequest interactionRequest) {
        return interactionService.addAnswer(interactionRequest);
    }

    @Override
    @GetMapping("/talk/get/{courseId}")
    public Interaction getTalk(@PathVariable("courseId") String courseId) {
        return interactionService.getTalk(courseId);
    }

    @Override
    @PostMapping("/talk/add")
    public ResponseResult addTalk(@RequestBody InteractionRequest interactionRequest) {
        return interactionService.addTalk(interactionRequest);
    }

    @Override
    @DeleteMapping("/talk/delete")
    public ResponseResult delTalk(@RequestParam("id") String id) {
        return interactionService.delTalk(id);
    }
}
